/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.com.transportes.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import pe.com.transportes.modelo.Admin;

/**
 *
 * @author z3phiroth
 */
public class AdminDAO {

      public void insertaradmin(Connection con,Admin c) throws SQLException{

    String sql ="insert into admin values (?,?,?,?)";
    PreparedStatement ps = con.prepareStatement(sql);

    ps.setInt(1,c.getCod_admin());
        ps.setString(2,c.getNom_admin());
        ps.setString(3, c.getApe_admin());
        ps.setString(4,c.getPass_admin());


    ps.executeUpdate();
    }
public Admin buscaradmin(Connection con,int codigo) throws SQLException{
    Admin bean = new Admin();
  String sql = "select * from admin where cod_admin=?";

        PreparedStatement ps = con.prepareStatement(sql);
        ps.setInt(1,codigo);

          ResultSet rs = ps.executeQuery();
        if(rs.next()){

          bean.setCod_admin(rs.getInt(1));
        bean.setNom_admin(rs.getString(2));
        bean.setApe_admin(rs.getString(3));
        bean.setPass_admin(rs.getString(4));

        }
        return bean;


}










}
